package com.cfpamf.ms.insur.pay.util;

import com.cfpamf.common.ms.exception.MSBizNormalException;
import com.cfpamf.ms.insur.pay.constant.BizExceptEnum;
import com.cfpamf.ms.insur.pay.integration.BankPayService;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zhangnayi
 */
@Slf4j
public class InsurUtil {

    /**
     * 获取第三方支付API
     *
     * @param payType
     * @return
     */
    public static BankPayService getBankPayService(String payType) {
        try {
            BankPayService bankPayService = SpringFactoryUtil.getBean(payType, BankPayService.class);
            if (bankPayService == null) {
                throw new MSBizNormalException(BizExceptEnum.PAY_TYPE_ERROR);
            }
            return bankPayService;
        } catch (Exception e) {
            log.warn("getBankPayService错误", e);
            throw new MSBizNormalException(BizExceptEnum.PAY_TYPE_ERROR);
        }
    }
}
